import { solid } from '@/api/map'
import { type FeatureCollection } from 'geojson'
/* let obj = {
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [
          121.47437596967607,
          29.801731625509913
        ]
      },
      "properties": {
        "FID": 13,
        "Id": 0
      },
      "id": 13
    }
  ]
} */

export function pointTogeojson (arr: Array<solid>): FeatureCollection {
  let obj: FeatureCollection = {
    "type": "FeatureCollection",
    "features": []
  }
  obj.features = arr.map((item: solid) => {
    return {
      type: "Feature",
      geometry: {
        "type": "Point",
        "coordinates": [
          item.lon,
          item.lat
        ]
      },
      properties: {
        FID: item.id,
        areaId: item.areaId,
        name: item.name,
        areaName: item.areaName,
        createId: item.createId,
        lon: item.lon,
        lat: item.lat,
        createTime: item.createTime,
        checkTime: item.checkTime,
        filePath: item.filePath
      },
      id: item.id
    }
  }) as any

  return obj
}